<%@page import="Entities.*"%>
<%@page import="Helpers.*"%>
<%@page import="Hibernate.*"%>
<%@page import="java.util.*"%>

<%@include file="../../views/header.jsp" %>
<%@include file="../../views/mainMenu.jsp" %>
<%@include file="../../views/userMenu.jsp" %>
<%@include file="../../views/cntColumnOpen.jsp" %>


     <%
        String id = (String) request.getParameter("eid");
        String s = (String) request.getParameter("enquetenaam");
        if (s == null) {
          EnqueteHelper ehelper = new EnqueteHelper();
          Enquetes enquete = ehelper.getEnquete(Integer.parseInt(id));
     %>

    <h3>Bewerken Enquete</h3>
    <p>U kunt nu uw enquete bewerken via deze pagina.</p>



<form id="form6" name="form6" class="wufoo leftLabel" method="post" action="webpages/Toetsen/showToets.jsp?id=<%=id%>">

    <ul>
        <li id="1" class="section">
            <h3 id="title8">Enquete behorende bij een cursus</h3>
        </li>
        <br />
        <li id="fo6li115" class="complex">
            <label class="desc" id="title115" for="curus">
                Cursus
                <span id="req_115" class="req">*</span>
            </label>
            <div>
                <select id="cursusid" name="cursusid" class="field select addr" tabindex="14" >
                    <%
                        CursusHelper cHelper = new CursusHelper();
                        List<Cursussen> cursussen = cHelper.getcursussen();
                        for (Cursussen cursus : cursussen) {
                     %>
                        <option value="<%=cursus.getId()%>"<% if (enquete.getCursussen().getId() == cursus.getId()) { %> selected="selected"<%} %>><%=cursus.getNaam()%></option>
                    <% }%>
                </select>
            </div>
        </li>

        <li id="2" class="complex">
           <label class="desc" id="title117" for="toets">
             Enquete <span id="req_117" class="req">*</span>
           </label>
           <span>
              <input id="Enquetenaam" name="Enquetenaam" type="text" class="field text" size="30"  value="<%=enquete.getNaam()%>" />
           </span>
        </li>

        <li id="3" class="complex">
           <label class="desc" id="title118" for="toets">
             Aantal vragen <span id="req_118" class="req">*</span>
           </label>
           <span>
              <input id="aantal_vragen" name="aantal_vragen" type="text" class="field text" size="5"  value="<%=enquete.getAantalVragen()%>"/>
           </span>
        </li>


    </ul>
    <br/>
    <input name="submit" type="submit" class="btn" tabindex="16" value="Update enquete" />
    <a href="webpages/Cursus/showEnquetes.jsp" class="btn">Terug</a>
    <a href="webpages/EnqueteVragen/showEnqueteVragen.jsp?eid=<%= enquete.getId()%>" class="btn">Enquetevragen</a>
</form>

 <%
   } else {
            EnqueteHelper ehelper = new EnqueteHelper();
            CursusHelper chelper = new CursusHelper();
            Enquetes enquete = ehelper.getEnquete(Integer.parseInt(id));

            enquete.setNaam((String) request.getParameter("Enquetenaam"));
            enquete.setAantalVragen((int) Integer.parseInt(request.getParameter("aantal_vragen")));
            enquete.setCursussen(chelper.getCursus(Integer.parseInt(request.getParameter("cursusid"))));

            ehelper.updateEnquete(enquete);

            response.sendRedirect("showCursussen.jsp");
        }
   %>



<div class="fix"></div>
<!--/post-->



<br class="fix" />


<%@include file="../../views/footer.jsp" %>
